package be.jabapage.snooker.service.administration.api;

import java.util.Set;

import be.jabapage.snooker.exception.EntityNotFoundException;
import be.jabapage.snooker.exception.MultipleInstanceFoundException;
import be.jabapage.snooker.jdo.administration.Player;

/**
 * 
 * CRUD service for the Player
 * @author axesq
 *
 */
public interface IPlayerService {

	/**
	 * 
	 * Store or update a Player in the data store
	 * @param Player
	 */
	void store(Player player);

	/**
	 * Retrieve a Player by the key
	 * @param key
	 * @return Player
	 * @throws EntityNotFoundException when no record is found
	 */
	Player retrieve(Long key) throws EntityNotFoundException;

	/**
	 * Delete the instance with this key from the datastore.
	 * @param key
	 * @throws EntityNotFoundException when the instance is not found;
	 */
	void delete(Long key) throws EntityNotFoundException;

	/**
	 * Retrieve a Player by the name
	 * @param name
	 * @return
	 * @throws MultipleInstanceFoundException when more then one instance is found.
	 * @throws EntityNotFoundException when no record is found
	 */
	Player retrieve(String name) throws MultipleInstanceFoundException, EntityNotFoundException;

	/**
	 * Retrieves a list of Player depending on the search criteria.  Wildcards are allowed.
	 * @param name
	 * @return a {@link Set}
	 */
	Set<Player> search(String name);

	/**
	 * Retrieves a set of Player that belongs to a certain club.
	 * @param regionId
	 * @return
	 */
	Set<Player> retrieveAllForClub(Long clubId);

	/**
	 * Retrieves a set of Player that belongs to a certain team.  
	 * If the parameter is null, retrieve all the players without a team.
	 * @param regionId
	 * @return
	 */
	Set<Player> retrieveAllForTeam(Long clubId);
}
